package com.keur.money.ui.user.adapter

import androidx.recyclerview.widget.RecyclerView
import com.keur.money.R
import com.keur.money.base.adapter.MullaRecyclerViewAdapter
import com.keur.money.base.adapter.MullaViewHolderHelper
import org.json.JSONObject

/**
 * MullaFlow
 * @Author wwdeng
 * @CreateTime: 2024/8/19 16:42
 * @Annotation：消息列表适配器
 */
class KeurUserMessageAdapter(recyclerView: RecyclerView?) : MullaRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_mulla_user_message) {
    override fun setItemChildListener(helper: MullaViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout)
    }

    override fun fillData(helper: MullaViewHolderHelper, position: Int, model: JSONObject) {
        helper.setText(R.id.textTitle,model.optString("title"))
        helper.setText(R.id.textTime,model.optString("timeDesc"))
        helper.setText(R.id.textDes,model.optString("content"))

        val imgView = helper.getImageView(R.id.imgView)
        when(model.optString("type")){
            "SIGN_REMINDER" -> {//签到
                imgView.setImageResource(R.mipmap.mulla_message_sign_icon)
            }
            "COUPON_REMINDER" -> {//优惠券
                imgView.setImageResource(R.mipmap.mulla_message_coupon_icon)
            }
            "UPGRADE_REMINDER" -> {//等级中心
                imgView.setImageResource(R.mipmap.mulla_message_upgrade_icon)
            }
            "REPAY_REMIDER" -> {//还款提醒
                imgView.setImageResource(R.mipmap.mulla_message_repayment_icon)
            }
            "APPLY_STATUS_UPDATE" -> {//申请状态更新
                imgView.setImageResource(R.mipmap.mulla_message_apply_update_icon)
            }
            else -> {//AD_MESSAGE  广告推广
                imgView.setImageResource(R.mipmap.mulla_message_custom_icon)
            }
        }
    }
}